package nio;

import java.util.*;

public class iterator1 {
    public static void main(String[] args) {
        String[] s1 =new String[]{"a","b"};



        Iterator<String> iterator = Arrays.stream(s1).iterator();
        while (iterator.hasNext()){
            String next = iterator.next();
            System.out.println(next);
        }


        ArrayList<String> sites = new ArrayList<String>();
        sites.add("Google");
        sites.add("Runoob");
        sites.add("Taobao");
        sites.add("Zhihu");

        // 获取迭代器
        Iterator<String> it = sites.iterator();

        // 输出集合中的第一个元素
//        System.out.println(it.next());
        it.next();
        it.remove();
//        System.out.println(it.next());
        System.out.println(sites);

        Set<String> set = new HashSet<>();
        set.add("ytt");
        set.add("ye");
        Iterator<String> iterator1 = set.iterator();
        iterator1.next();
        iterator1.remove();
        System.out.println(set);

    }
}
